#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair

using namespace std;

typedef pair<int, int> pii;
const int MAXN = 1e5 + 10;
const int MAXL = 1e6 + 10;
long long d[MAXN], v[MAXN], a[MAXN], p[MAXN];
pii b[MAXN];
int t, n, m, l;
int np[MAXL];
long long fv;

bool cmp(const pii &x, const pii &y) {
    if (x.sc != y.sc) return x.sc < y.sc;
    else return x.fr > y.fr;
}

void solve() {
    int ans1 = 0, ans2 = 0;
    cin >> n >> m >> l >> fv;
    for (int i = 1; i <= n; ++i) cin >> d[i] >> v[i] >> a[i];
    for (int i = 1; i <= m; ++i) {
        cin >> p[i];
        b[i].fr = 0;
        b[i].sc = 0;
    }
    fv *= fv;
    int sum = 1, cnt = 0;
    for (int i = 0; i <= l; ++i) {
        np[i] = sum;
        if (sum > m) continue;
        if (i == p[sum]) sum++;
    }
    for (int i = 1; i <= n; ++i) {
        if (np[d[i]] > m) continue;
        if (!a[i]) {
            if (v[i] * v[i] > fv) {
                b[++cnt].fr = np[d[i]];
                b[cnt].sc = m;
                ans2++;
            }
            continue;
        }
        if (a[i] > 0) {
            if (fv >= 2 * (p[m] - d[i]) * a[i] + v[i] * v[i]) continue;
            ans2++;
            int L = np[d[i]], R = m, mid;
            while(L < R) {
                mid = (L + R) >> 1;
                if (fv < 2 * (p[mid] - d[i]) * a[i] + v[i] * v[i]) R = mid;
                else L = mid + 1;
            }
            //cout << np[d[i]] << ' ' << L << endl;
            b[++cnt].fr = L;
            b[cnt].sc = m;
        }
        else {
            if (fv >= 2 * (p[np[d[i]]] - d[i]) * a[i] + v[i] * v[i]) continue;
            ans2++;
            int L = np[d[i]], R = m, mid;
            while(L < R) {
                mid = ((L + R) >> 1) + 1;
                if (fv >= 2 * (p[mid] - d[i]) * a[i] + v[i] * v[i]) R = mid - 1;
                else L = mid;
            }
            b[++cnt].fr = np[d[i]];
            b[cnt].sc = L;
        }
    }
    sort(b + 1, b + 1 + cnt, cmp);
    if (ans2 == 1 || ans2 == 0) {
        if (ans2 == 1) ans1 = 1;
        else ans1 = 0;
        ans1 = m - ans1;
    }
    else {
        int r = 1;
        ans1 = 1;
       // cout << b[1].fr << ' ' << b[1].sc << "\n";
        for (int i = 2; i <= cnt; ++i) {
            //cout << b[i].fr << ' ' << b[i].sc << "\n";
            if (b[r].sc < b[i].fr) ans1++, r = i;
        }
        ans1 = m - ans1;
    }
    cout << ans2 << ' ' << ans1 << "\n";
}

int main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> t;
    while(t--) solve();
    return 0;
}
/*
1
10 10 145322 772
10139 897 -47
86524 947 -2
51251 982 -2
12573 962 -2
14068 919 -163
10944 994 -6
35650 999 -9
3804 977 -1
1149 905 -2
43935 932 -2
10519 11805 14747 28890 37732 45509 55779 80531 108392 126659
*/